import Vue from 'vue';
import VueRouter from 'vue-router';

/* Layout */
import MallLayout from 'views/layout/MallLayout.vue';



Vue.use(VueRouter);

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('views/Login.vue'),
  },
  {
    path: '/',
    component: MallLayout,
    redirect: '/home',
    children: [{
      path: '/home',
      name: 'home',
      component: () => import('views/home/home.vue'),
      meta: { title: '首页', icon: 'home' },
    },
    {
      path: '/category',
      name: 'category',
      component: () => import('views/category/category.vue'),
      meta: { title: '分类', icon: 'category' },
    },
    {
      path: '/user',
      name: 'user',
      component: () => import('views/user/user.vue'),
      meta: { title: '我的', icon: '' },
    }

    ],
  },
];
const router = new VueRouter({
  routes,
  mode: 'history',
  watch: {
    '$route'(to, from) {
      this.$router.go(0);
    }
  },
});
export default router;
